<template>
	<view>
 
		<list1 :list="shop_list" :islog="islog" :log="log"> </list1>
 

	</view>
</template>

<script>
	import list1 from "./list1.vue";
 
 
	export default {
		components: {
			list1
		},
		data() {
			return {
				shop_list: [],
 
				islog: true,
				log: '加载中',
				NavList: [],
				tabb: '智能排序',
				navname: '全部分类',
				tab_listb: [{
					"id": 2,
					"name": "智能排序",
					"sort": 0
				}, {
					"id": 3,
					"name": "离我最近",
					"sort": 1
				}, {
					"id": 4,
					"name": "最新入住",
					"sort": 2
				}],
				lei: 0,
				nav_id: 0
			}
		},
		onLoad(on) {
			var pages = getCurrentPages()
			let currentRoute = pages[pages.length - 1].route;
			this.api_path = currentRoute.match(/pages\/(\S*)\//)[1];
			this.nav_id = on.id;
			this.page = 1;
			this.shop_init();
		},
		methods: {
			on_xz(id, name) {
				this.nav_id = id;
				this.shop_list = [];
				this.islog = true;
				this.page = 1;
				this.log = '加载中';
				this.navname = name;
				this.shop_init();

			},
			on_xza(id, name) {
				this.shop_list = [];
				this.islog = true;
				this.page = 1;
				this.log = '加载中';
				this.tabb = name;
				this.tabindex = id;
			 
				this.shop_init();
			},
			onnav(id) {
				this.lei = id;

				this.$refs.alertDialog.open('top')
			},
			shop_init() {
				var that = this;
				let requestParams = {
					user_id: uni.getStorageSync('user_id'),
					token: uni.getStorageSync('token'),
					page: this.page,
					tabindex: this.tabindex,
					nav_id: this.nav_id
				};
				 
				this.Http.post('/plugin.php/banmichaoqiangbizhi/api/index/shop_list',requestParams).then(ret => {
				 

					if (ret.status == 200) {
						if (that.page == 1) {
							this.shop_list = ret.data.shop_list.data;
							this.NavList = ret.data.NavList;
							if (this.nav_id>0) {
								for (var i = 0; i < this.NavList.length; i++) {
									if (this.nav_id==this.NavList[i]['id']) {
										this.navname =	this.NavList[i]['name']
									}  
								 
								}
							 
							}  

						} else {
							if (ret.data.shop_list.data.length > 0) {
								for (var i = 0; i < ret.data.shop_list.data.length; i++) {
									that.shop_list.push(ret.data.shop_list.data[i]);
								}
							}
							if (ret.data.shop_list.data < 10) {
								this.log = "没有数据了"
							}
						}
						setTimeout(() => {
							that.isinit = false;
							that.islog = false;
						}, 100)


					}



				})
			},

		}
	}
</script>

<style>
 page{
	 background-color: #fff;
 }
</style>
